<template>
  <div class="tablists">
    <el-table
      :cell-style="$rowstyle"
      :header-cell-style="$headerstyle"
      :data="tableData"
      style="width: 100%"
    >
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="medium_public.get_unit.name" label="部门/单位"></el-table-column>
      <el-table-column prop="medium_public.get_media.name" label="频道"></el-table-column>
      <el-table-column prop="medium_public.get_program.name" label="广告位置"></el-table-column>
      <el-table-column label="播出日期">
        <template slot-scope="scope">

          <div v-if="type == 2 || type == 3">
            <span
              v-if="scope.row.player_date"
            >{{transDate(Number(JSON.parse(scope.row.player_date).val[0])) + '~' + transDate(Number(JSON.parse(scope.row.player_date).val.pop()))}}</span>
            <span v-else>无</span>
          </div>
          <span v-else>{{scope.row.player_date[0] + '~' + scope.row.player_date[1]}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="expenses" label="费用"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click="handleDelte(scope.row)" type="text" size="small">删除</el-button>
          <el-button type="text" @click="handleChange(scope.row)" size="small">变更</el-button>
          <!-- <el-button type="text" @click="handleLog(scope.row)" size="small">日志</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- <div class="block">
          <el-pagination layout="prev, pager, next" :total="tableData.length"></el-pagination>
    </div>-->
  </div>
</template>

<script>
import moment from "moment";
export default {
  name: "resourceList",
  props: ["tableData", "type"],
  // type :查看
  data() {
    return {
      visible: false,
      interval: null,
      isMoving: false,

    };
  },


  beforeDestroy() {},
  methods: {
    handleDelte(e) {
      this.$emit("handleResourceDelete", e);
    },
    handleChange(e) {
      this.$emit("handleResourceChange", e);
    },
    transDate(time){
      return moment.unix(time).format("YYYY-MM-DD")
    },
    handleLog(e) {}
  }
};
</script>

<style scoped>
.tablists {
  width: 95%;
  padding-left: 5%;
  margin-top: 20px;
}
</style>
